package com.str.algorithm;
import java.io.*;

public class Rendering {

  private static String render(int i, int r) {
    if (i < 0)
      return "-" + render(-i, r);
    else if (i < r) {
      char d = (char)('0' + i);
      return String.valueOf(d);
    }
    else {
      char d = (char)('0' + (i%r));
      return render(i/r, r) + String.valueOf(d);
    }
  }

  public static void main(String[] args) throws IOException {
    BufferedReader stdin = new BufferedReader(
                           new InputStreamReader(System.in));
    System.out.print("Enter an integer: ");
    String inputLine = stdin.readLine();
    int i = Integer.parseInt(inputLine);
    for (int b = 2; b <= 10; b++) {
      System.out.print("Base " + b);
      System.out.println("   " + render(i, b));
    }
  }
}
